package com.itwill.ecom.orders;

import java.util.HashMap;
import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class OrdersDaoImpl implements OrdersDao {
	public final static String namespace = "com.itwill.ecom.orders.OrdersMapper";
	
	@Autowired
	SqlSession sql;	

	public OrdersDaoImpl() {
	}

	@Override
	public int create(OrdersBeans ordersBeans) {
		return sql.insert(namespace + ".create", ordersBeans);
	}

	@Override
	public List<OrdersBeans> readByMemberNo(HashMap<String, String> pagemap) {		
		return sql.selectList(namespace + ".readByMemberNo", pagemap);
	}
	
	@Override
	public OrdersBeans readByOrdersNo(int orders_no) {
		return sql.selectOne(namespace + ".readByOrdersNo", orders_no);
	}
	
	@Override
	public int readMaxOrdersNo(int memberNo){
		return sql.selectOne(namespace + ".readMaxOrdersNo", memberNo);
	}
	
	@Override
	public int readCount(int memberNo){
		return sql.selectOne(namespace + ".readCountByMemberNo", memberNo);
	}

	@Override
	public int delete(int orders_no) {
		return sql.delete(namespace + ".delete", orders_no);
	}

}
